GO
IF OBJECT_ID ( 'createModuleFilter', 'P' ) IS NOT NULL 
    DROP PROCEDURE [dbo].[createModuleFilter];
GO
CREATE PROCEDURE [dbo].[createModuleFilter]
	@FilterName VARCHAR(40)
AS
BEGIN
	DECLARE @FilterId INT
    INSERT INTO [FILTER] ([NAME], [TABLE_NAME], [TYPE])
		VALUES(@FilterName, 'EducationModule', 'System')
	SET @FilterId = @@IDENTITY;
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'EducationModuleId', 'EducationModule', 'Id', 'Text')
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'EducationModuleName', 'EducationModule', 'Name', 'Text')
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'EducationModuleDescription', 'EducationModule', 'Description', 'Text')
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'EducationModuleHoldingType', 'EducationModule', 'HoldingType', 'Text')
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'EducationModuleParticipantType', 'EducationModule', 'ParticipantType', 'Text')
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'UserId', 'Users', 'Id', 'Text')
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'UserLogin', 'Users', 'Login', 'Text')
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'UserName', 'Users', 'Name', 'Text')
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'UserSurname', 'Users', 'Surname', 'Text')
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'UserMiddleName', 'Users', 'MiddleName', 'Text')
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'UserEmail', 'Users', 'Email', 'Text')
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'UserTelephon', 'Users', 'Telephon', 'Text')
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'DependModuleId', 'DependModules', 'Id', 'Text')
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'DependModuleName', 'DependModules', 'Name', 'Text')
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'DependModuleDescription', 'DependModules', 'Description', 'Text')
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'GroupId', 'Groups', 'Id', 'Text')
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'GroupName', 'Groups', 'Name', 'Text')
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'GroupDescription', 'Groups', 'Description', 'Text')
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'DocId', 'Docs', 'Id', 'Text')
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'DocName', 'Docs', 'Name', 'Text')
	INSERT INTO [FILTER_FIELD]
		([FILTER_ID], [FIELD_NAME], [TABLE_NAME], [COLUMN_NAME], [TYPE])
		VALUES (@FilterId, 'DocDescription', 'Docs', 'Description', 'Text')
END
GO
